﻿using DLLPC.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace VisionCore
{
    public class DelayOnHelper_Exc
    {
        private static Thread thread;
        private static bool isRun = true;

        public static void Start()
        {
            thread = new Thread(TreadFunc);
            thread.IsBackground = true;
            thread.Start();
        }

        public static void Quit()
        {
            isRun = false;
        }

        private static void TreadFunc()
        {
            while (isRun)
            {               
                CV1_LDReq.Monitor(2000);
                CV1_UnReq.Monitor(2000);
                CV2_LDReq.Monitor(2000);
                CV2_UnReq.Monitor(2000);
                Insp1_LDReq.Monitor(2000);
                Insp1_UnReq.Monitor(2000);
                Insp2_LDReq.Monitor(2000);
                Insp2_UnReq.Monitor(2000);
                Insp3_LDReq.Monitor(2000);
                Insp3_UnReq.Monitor(2000);
                Insp4_LDReq.Monitor(2000);
                Insp4_UnReq.Monitor(2000);

                CV1_PresenceError.Monitor(2000);
                CV2_PresenceError.Monitor(2000);
                Insp1_PresenceError.Monitor(2000);
                Insp2_PresenceError.Monitor(2000);
                Insp3_PresenceError.Monitor(2000);
                Insp4_PresenceError.Monitor(2000);

                Insp1_VacError.Monitor(2000);
                Insp2_VacError.Monitor(2000);
                Insp3_VacError.Monitor(2000);
                Insp4_VacError.Monitor(2000);

                CV1_UpError.Monitor(2000);
                CV1_DnError.Monitor(2000);
                CV2_UpError.Monitor(2000);
                CV2_DnError.Monitor(2000);
                Insp1_UpError.Monitor(2000);
                Insp1_DnError.Monitor(2000);
                Insp2_UpError.Monitor(2000);
                Insp2_DnError.Monitor(2000);
                Insp3_UpError.Monitor(2000);
                Insp3_DnError.Monitor(2000);
                Insp4_UpError.Monitor(2000);
                Insp4_DnError.Monitor(2000);

                CV1_Y_AtWait.Monitor(2000);
                CV1_Y_AtWork.Monitor(2000);
                CV2_Y_AtWait.Monitor(2000);
                CV2_Y_AtWork.Monitor(2000);

                CV1_TrackSW_Y_AtLDPt1.Monitor(2000);
                CV1_TrackSW_Y_AtLDPt2.Monitor(2000);
                CV1_TrackSW_Y_AtInsp1.Monitor(2000);
                CV1_TrackSW_Y_AtInsp2.Monitor(2000);
                CV2_TrackSW_Y_AtLDPt1.Monitor(2000);
                CV2_TrackSW_Y_AtLDPt2.Monitor(2000);
                CV2_TrackSW_Y_AtInsp1.Monitor(2000);
                CV2_TrackSW_Y_AtInsp2.Monitor(2000);

                CCD1_X_AtCH1Mark.Monitor(2000);
                CCD1_X_AtCH1Work.Monitor(2000);
                CCD1_X_AtCH2Mark.Monitor(2000);
                CCD1_X_AtCH2Work.Monitor(2000);
                CCD1_Y_AtCH1Mark.Monitor(2000);
                CCD1_Y_AtCH1Work.Monitor(2000);
                CCD1_Y_AtCH2Mark.Monitor(2000);
                CCD1_Y_AtCH2Work.Monitor(2000);
                CCD1_Z_AtCH1Mark.Monitor(2000);
                CCD1_Z_AtCH1Work.Monitor(2000);
                CCD1_Z_AtCH2Mark.Monitor(2000);
                CCD1_Z_AtCH2Work.Monitor(2000);

                CCD2_X_AtCH1Mark.Monitor(2000);
                CCD2_X_AtCH1Work.Monitor(2000);
                CCD2_X_AtCH2Mark.Monitor(2000);
                CCD2_X_AtCH2Work.Monitor(2000);
                CCD2_Y_AtCH1Mark.Monitor(2000);
                CCD2_Y_AtCH1Work.Monitor(2000);
                CCD2_Y_AtCH2Mark.Monitor(2000);
                CCD2_Y_AtCH2Work.Monitor(2000);
                CCD2_Z_AtCH1Mark.Monitor(2000);
                CCD2_Z_AtCH1Work.Monitor(2000);
                CCD2_Z_AtCH2Mark.Monitor(2000);
                CCD2_Z_AtCH2Work.Monitor(2000);

                Insp1_Y_AtWork.Monitor(2000);
                Insp1_Y_AtWait.Monitor(2000);
                Insp2_Y_AtWork.Monitor(2000);
                Insp2_Y_AtWait.Monitor(2000);
                Insp3_Y_AtWork.Monitor(2000);
                Insp3_Y_AtWait.Monitor(2000);
                Insp4_Y_AtWork.Monitor(2000);
                Insp4_Y_AtWait.Monitor(2000);

                Insp1_RM_Z_AtWork.Monitor(2000);
                Insp1_RM_Z_AtWait.Monitor(2000);
                Insp2_RM_Z_AtWork.Monitor(2000);
                Insp2_RM_Z_AtWait.Monitor(2000);
                Insp3_RM_Z_AtWork.Monitor(2000);
                Insp3_RM_Z_AtWait.Monitor(2000);
                Insp4_RM_Z_AtWork.Monitor(2000);
                Insp4_RM_Z_AtWait.Monitor(2000);






                SystemTimeCounter.timeBeginPeriod(1);
                Thread.Sleep(1);
                SystemTimeCounter.timeEndPeriod(1);
            }
        }

        public static DelayOn CV1_LDReq = new DelayOn("入料口CV1入料请求延时");
        public static DelayOn CV1_UnReq = new DelayOn("入料口CV1出料请求延时");
        public static DelayOn CV2_LDReq = new DelayOn("入料口CV2入料请求延时");
        public static DelayOn CV2_UnReq = new DelayOn("入料口CV2出料请求延时");

        public static DelayOn Insp1_LDReq = new DelayOn("检测模组1入料请求延时");
        public static DelayOn Insp1_UnReq = new DelayOn("检测模组1出料请求延时");
        public static DelayOn Insp2_LDReq = new DelayOn("检测模组2入料请求延时");
        public static DelayOn Insp2_UnReq = new DelayOn("检测模组2出料请求延时");
        public static DelayOn Insp3_LDReq = new DelayOn("检测模组3入料请求延时");
        public static DelayOn Insp3_UnReq = new DelayOn("检测模组3出料请求延时");
        public static DelayOn Insp4_LDReq = new DelayOn("检测模组4入料请求延时");
        public static DelayOn Insp4_UnReq = new DelayOn("检测模组4出料请求延时");

        public static DelayOn CV1_PresenceError = new DelayOn("入料CV1在席异常延时");
        public static DelayOn CV2_PresenceError = new DelayOn("入料CV1在席异常延时");
        public static DelayOn Insp1_PresenceError = new DelayOn("检测模组1在席异常延时");
        public static DelayOn Insp2_PresenceError = new DelayOn("检测模组2在席异常延时");
        public static DelayOn Insp3_PresenceError = new DelayOn("检测模组3在席异常延时");
        public static DelayOn Insp4_PresenceError = new DelayOn("检测模组4在席异常延时");

        public static DelayOn Insp1_VacError = new DelayOn("检测模组1真空异常延时");
        public static DelayOn Insp2_VacError = new DelayOn("检测模组2真空异常延时");
        public static DelayOn Insp3_VacError = new DelayOn("检测模组3真空异常延时");
        public static DelayOn Insp4_VacError = new DelayOn("检测模组4真空异常延时");

        public static DelayOn CV1_UpError  = new DelayOn("入料CV1气缸上升异常延时");
        public static DelayOn CV1_DnError  = new DelayOn("入料CV1气缸下降异常延时");
        public static DelayOn CV2_UpError  = new DelayOn("入料CV2气缸上升异常延时");
        public static DelayOn CV2_DnError  = new DelayOn("入料CV2气缸下降异常延时");
        public static DelayOn Insp1_UpError = new DelayOn("入料Insp1气缸上升异常延时");
        public static DelayOn Insp1_DnError = new DelayOn("入料Insp1气缸下降异常延时");
        public static DelayOn Insp2_UpError = new DelayOn("入料Insp2气缸上升异常延时");
        public static DelayOn Insp2_DnError = new DelayOn("入料Insp2气缸下降异常延时");
        public static DelayOn Insp3_UpError = new DelayOn("入料Insp3气缸上升异常延时");
        public static DelayOn Insp3_DnError = new DelayOn("入料Insp3气缸下降异常延时");
        public static DelayOn Insp4_UpError = new DelayOn("入料Insp4气缸上升异常延时");
        public static DelayOn Insp4_DnError = new DelayOn("入料Insp4气缸下降异常延时");



        public static DelayOn CV1_Y_AtWait = new DelayOn("CV1_1去待命位延时");
        public static DelayOn CV1_Y_AtWork = new DelayOn("CV1_1去工作位延时");  
        public static DelayOn CV2_Y_AtWait = new DelayOn("CV1_2去待命位延时");
        public static DelayOn CV2_Y_AtWork = new DelayOn("CV1_2去工作位延时");

        public static DelayOn CV1_TrackSW_Y_AtLDPt1 = new DelayOn("CV1轨道切换去接料位1延时");
        public static DelayOn CV1_TrackSW_Y_AtLDPt2 = new DelayOn("CV1轨道切换去接料位2延时");
        public static DelayOn CV1_TrackSW_Y_AtInsp1 = new DelayOn("CV1轨道切换去检测位1延时");
        public static DelayOn CV1_TrackSW_Y_AtInsp2 = new DelayOn("CV1轨道切换去检测位2延时");
        public static DelayOn CV2_TrackSW_Y_AtLDPt1 = new DelayOn("CV2轨道切换去接料位1延时");
        public static DelayOn CV2_TrackSW_Y_AtLDPt2 = new DelayOn("CV2轨道切换去接料位2延时");
        public static DelayOn CV2_TrackSW_Y_AtInsp1 = new DelayOn("CV2轨道切换去检测位1延时");
        public static DelayOn CV2_TrackSW_Y_AtInsp2 = new DelayOn("CV2轨道切换去检测位2延时");

        public static DelayOn CCD1_X_AtCH1Mark = new DelayOn("CCD1_X去CH1_Mark位延时");
        public static DelayOn CCD1_X_AtCH1Work = new DelayOn("CCD1_X去CH1_Work位延时");
        public static DelayOn CCD1_X_AtCH2Mark = new DelayOn("CCD1_X去CH2_Mark位延时");
        public static DelayOn CCD1_X_AtCH2Work = new DelayOn("CCD1_X去CH2_Work位延时");

        public static DelayOn CCD1_Y_AtCH1Mark = new DelayOn("CCD1_Y去CH1_Mark位延时");
        public static DelayOn CCD1_Y_AtCH1Work = new DelayOn("CCD1_Y去CH1_Work位延时");
        public static DelayOn CCD1_Y_AtCH2Mark = new DelayOn("CCD1_Y去CH2_Mark位延时");
        public static DelayOn CCD1_Y_AtCH2Work = new DelayOn("CCD1_Y去CH2_Work位延时");

        public static DelayOn CCD1_Z_AtCH1Mark = new DelayOn("CCD1_Z去CH1_Mark位延时");
        public static DelayOn CCD1_Z_AtCH1Work = new DelayOn("CCD1_Z去CH1_Work位延时");
        public static DelayOn CCD1_Z_AtCH2Mark = new DelayOn("CCD1_Z去CH2_Mark位延时");
        public static DelayOn CCD1_Z_AtCH2Work = new DelayOn("CCD1_Z去CH2_Work位延时");

        public static DelayOn CCD2_X_AtCH1Mark = new DelayOn("CCD2_X去CH1_Mark位延时");
        public static DelayOn CCD2_X_AtCH1Work = new DelayOn("CCD2_X去CH1_Work位延时");
        public static DelayOn CCD2_X_AtCH2Mark = new DelayOn("CCD2_X去CH2_Mark位延时");
        public static DelayOn CCD2_X_AtCH2Work = new DelayOn("CCD2_X去CH2_Work位延时");

        public static DelayOn CCD2_Y_AtCH1Mark = new DelayOn("CCD2_Y去CH1_Mark位延时");
        public static DelayOn CCD2_Y_AtCH1Work = new DelayOn("CCD2_Y去CH1_Work位延时");
        public static DelayOn CCD2_Y_AtCH2Mark = new DelayOn("CCD2_Y去CH2_Mark位延时");
        public static DelayOn CCD2_Y_AtCH2Work = new DelayOn("CCD2_Y去CH2_Work位延时");

        public static DelayOn CCD2_Z_AtCH1Mark = new DelayOn("CCD2_Z去CH1_Mark位延时");
        public static DelayOn CCD2_Z_AtCH1Work = new DelayOn("CCD2_Z去CH1_Work位延时");
        public static DelayOn CCD2_Z_AtCH2Mark = new DelayOn("CCD2_Z去CH2_Mark位延时");
        public static DelayOn CCD2_Z_AtCH2Work = new DelayOn("CCD2_Z去CH2_Work位延时");

        public static DelayOn Insp1_Y_AtWork = new DelayOn("Insp1_Y轴去夹持位延时");
        public static DelayOn Insp1_Y_AtWait = new DelayOn("Insp1_Y轴去等待位延时");
        public static DelayOn Insp2_Y_AtWork = new DelayOn("Insp2_Y轴去夹持位延时");
        public static DelayOn Insp2_Y_AtWait = new DelayOn("Insp2_Y轴去等待位延时");
        public static DelayOn Insp3_Y_AtWork = new DelayOn("Insp3_Y轴去夹持位延时");
        public static DelayOn Insp3_Y_AtWait = new DelayOn("Insp3_Y轴去等待位延时");
        public static DelayOn Insp4_Y_AtWork = new DelayOn("Insp4_Y轴去夹持位延时");
        public static DelayOn Insp4_Y_AtWait = new DelayOn("Insp4_Y轴去等待位延时");

        public static DelayOn Insp1_RM_Z_AtWork = new DelayOn("Insp1_RM_Z轴去顶升位延时");
        public static DelayOn Insp1_RM_Z_AtWait = new DelayOn("Insp1_RM_Z轴去等待位延时");
        public static DelayOn Insp2_RM_Z_AtWork = new DelayOn("Insp2_RM_Z轴去顶升位延时");
        public static DelayOn Insp2_RM_Z_AtWait = new DelayOn("Insp2_RM_Z轴去等待位延时");
        public static DelayOn Insp3_RM_Z_AtWork = new DelayOn("Insp3_RM_Z轴去顶升位延时");
        public static DelayOn Insp3_RM_Z_AtWait = new DelayOn("Insp3_RM_Z轴去等待位延时");
        public static DelayOn Insp4_RM_Z_AtWork = new DelayOn("Insp4_RM_Z轴去顶升位延时");
        public static DelayOn Insp4_RM_Z_AtWait = new DelayOn("Insp4_RM_Z轴去等待位延时");
       
    }
}
